home *** CD-ROM | disk | FTP | other *** search
- Path: kettle.magna.com.au!news
- From: peter@magna.com.au (Peter J Brock)
- Newsgroups: comp.lang.c++
- Subject: Re: STL container classes and destroy()
- Date: Fri, 09 Feb 1996 06:39:25 GMT
- Organization: Me
- Message-ID: <4fcn8h$7pq@kettle.magna.com.au>
- References: <Pine.BSF.3.91.960204202036.7806A-100000@cyb.gridpoint.com>
- Reply-To: peter@magna.com.au
- NNTP-Posting-Host: enterprise.magna.com.au
- X-Newsreader: Forte Free Agent v0.55
-
- "Bruce J. Keeler" <loodvrij@cyb.gridpoint.com> wrote:
-
- >Hi. I have a question about the STL container classes and their use with
- >user-defined types. The test program below fails to compile as shown.
- >If I use vector<asdf *> it compiles but gives a warning similar to the message
- >shown.
-
- >In the stl defalloc.h file I notice a whole bunch of versions of
- >destroy(foo) one for each built-in type. Are we expected to include similar
- >definitions in the header files for our classes? Doing so certainly seems
- >to get rid of the messages, but it still seems kinda klunky and possibly
- >just darn wrong to me.
-
- >Compiler is the AIX xlC compiler, version (I think) 1.1.2.
-
- >Thanks.
- >---------------------------------------8<---------------------------------
- >#include <vector.h>
-
- >class asdf
- >{
- > asdf() {}
- > ~asdf() {}
- > int spam;
- >};
-
- >class Blah
- >{
- > vector<asdf> asdfList;
- >};
-
- >int main (int, char **)
- >{
- > Blah blah;
- >}
-
- >xlC -+ -U__STR__ -Istl -g
- >-DMOD_SYM=3Dctgnd -DMODULE_NAME=3D"ctgnd" -c vector-test.cc
- >"stl/defalloc.h", line 74.1: 1540-013: (S) "~T" is undefined.
- >"stl/defalloc.h", line 73.1: 1540-207: (I) The previous message applies
- >to the definition of template "destroy(asdf*)".
-
-
-
-
-
- >Bruce J. Keeler Internet: loodvrij@gridpoint.com
- >-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- >"Never trust an Operating System you don't have source code for."
-
- I tried your code under my compiler. Microsoft Visual C++ 4.0 using
- two different versions of STL.
-
- 1) HP implementation that ships with MS VC++ 4.0, gives
- ---------Configuration: test - Win32 Debug--------------------
- Compiling...
- test1.cpp
- E:\DEVAPPS\stl\hp\STL\iterator.h(65) : warning C4114: same type
- qualifier used more than once
- E:\DEVAPPS\stl\hp\STL\iterator.h(65) : warning C4114: same type
- qualifier used more than once
- Linking...
- test.exe - 0 error(s), 2 warning(s)
-
- 2) ObjectSpace STL<ToolKit>, gives
- ---------Configuration: test - Win32 Debug--------------------
- Compiling...
- test1.cpp
- D:\deriv\TOOLS\OSPACE\ospace\stl\basalgo.cc(412) : error C2678: binary
- '<' : no operator defined which takes a left-hand operand of type
- 'const class asdf' (or there is no acceptable conversion) (new
- behavior; please see help)
- D:\deriv\TOOLS\OSPACE\ospace\stl\basalgo.cc(415) : error C2678: binary
- '<' : no operator defined which takes a left-hand operand of type
- 'const class asdf' (or there is no acceptable conversion) (new
- behavior; please see help)
- Error executing cl.exe.
- test.exe - 2 error(s), 0 warning(s)
-
- Niether gave me the error message that you had.
-
- I guess the problem could lay with the compiler, since I'm
- assuming you are using the HP STL.
-
- Appart from that, the only suggestion I can make is from the
- FAQ. Provide the BIG THREE,
- Destructor, copy constructor, and assignment operator.
-
-
- Cheers,
- Peter J Brock
- http://www.magna.com.au/~peter
-
-